<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>使用v-on指令调用自定义方法动态输出单击次数</title>
<!--引入Vue库-->
<script src="vue.js"></script>
</head>
<body>
<div id="app">
   <button v-on:click="changeNum">单击</button>
   <p>{{ message }}</p>
</div>
<script>
var vm = new Vue({
  el: '#app',
  data:{
    counter:0,
    message:''
  },
  methods: {
    changeNum: function (event) {
      if (event) {
        this.message = '这个按钮被'+event.target.innerHTML + '了' + ++this.counter + '次';
      }
    }
  }
})
</script>
</body>
</html>
